import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

class FlexPage extends StatefulWidget {
  @override
  _FlexPageState createState() => _FlexPageState();
}

class _FlexPageState extends State<FlexPage> {
  List<String> list = ['one', 'two', 'three', 'four', 'five', 'six', 'seven'];
  String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

  void _saveTabOffsets(List<double> tabOffsets, TextDirection textDirection, double width) {
    // _tabStripWidth = width;
    // _indicatorPainter?.saveTabOffsets(tabOffsets, textDirection);
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Column(
        children: <Widget>[
          Text('不用Expanded'),
          Flex(
            children: <Widget>[
              Text('one'),
              Text('tow'),
              Text('three'),
            ],
            direction: Axis.horizontal,
          ),
          Text('用Expanded'),
          Flex(
            children: <Widget>[
              Expanded(
                child: Text('one'),
              ),
              Expanded(
                child: Text('two'),
              ),
              Expanded(
                child: Text('three'),
              ),
            ],
            direction: Axis.horizontal,
          ),
          Text('用Expanded'),
          SingleChildScrollView(
            padding: EdgeInsets.all(16.0),
            scrollDirection: Axis.horizontal,
            child: Center(
              child: Flex(
                //动态创建一个List<Widget>
                children: str
                    .split("")
                    //每一个字母都用一个Text显示,字体为原来的两倍
                    .map((c) => Text(
                          c,
                          textScaleFactor: 2.0,
                        ))
                    .toList(), direction: Axis.horizontal,
              ),
            ),
          ),
        ],
      ),
    );
  }
}